package com.ohc.leetcode.链表;

import java.util.ArrayList;
import java.util.List;

/**
 * 2022年6月18日11:27:25
 * https://leetcode.cn/problems/palindrome-linked-list-lcci/
 */
public class 面试题0206回文链表 {

    public static class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }

    public static boolean isPalindrome(ListNode head) {
        List<Integer> list = new ArrayList<>();
        while (head != null) {
            list.add(head.val);
            head = head.next;
        }
        int left = 0;
        int right = list.size() - 1;
        for (int i = 0; i < list.size(); i++) {
            if (!list.get(left).equals(list.get(right))) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
//        isPalindrome();
    }
}
